from pywebio import *
from startPywebio8001 import start8001
import uuid

def get_mac_address():
    mac=uuid.UUID(int = uuid.getnode()).hex[-12:]
    return ":".join([mac[e:e+2] for e in range(0,11,2)])

def count(mac):
    import hashlib
    sha1 = hashlib.sha1()
    data = str(mac) + 'hr' + str(mac)
    sha1.update(data.encode('utf-8'))
    sha1_data = sha1.hexdigest()
    return sha1_data

def main():  # PyWebIO application function
    mac = get_mac_address()
    output.put_text("your mac is :", mac)
    password = input.input("input password")
    print(count(mac))
    if password == count(mac):
        output.put_text("ok you can use it")
        start8001()
    else:
        output.put_text("No you can not use it")
        main()
start_server(main, port=8002, debug=True)